package com.wlyuan.open.domain.source.assembler;

import com.wlyuan.basic.dto.goods.GoodsRewriteDTO;
import com.wlyuan.core.domain.MappingIds;
import com.wlyuan.core.domain.conversion.MappingConversions;
import com.wlyuan.core.marker.NamedStatus;
import com.wlyuan.open.dto.OpenGoodsSyncDTO;
import lombok.var;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
 * @author yuanzheng
 */
public class GoodsAssembler {

    private static final Assembler ASSEMBLER = Mappers.getMapper(Assembler.class);

    @Mapper(uses = {
            MappingIds.class,
            MappingConversions.class,
    }, imports = {
            NamedStatus.class,
    })
    public interface Assembler {
        GoodsRewriteDTO assemble(OpenGoodsSyncDTO source);
    }

    public static GoodsRewriteDTO assemble(OpenGoodsSyncDTO source, Long customerId) {
        var goods = ASSEMBLER.assemble(source);
        goods.setCustomerId(customerId);
        return goods;
    }
}
